<?php

namespace app\common\model;

use think\Model;
use Exception;

class News extends Model
{

    protected $pk = 'news_id';

    public function handler($data)
    {
        try {
            if (empty($data)) return null;
            $data['add_time_handler'] = handler_time($data['add_time']);
            $data['add_time_text'] = format_time($data['add_time']);
            return $data;
        } catch (Exception $e) {
            return $data;
        }
    }

    public function getList($page)
    {
        try {
            if (empty($page)) return null;
            $data = $this->limit(PAGE_NUMBER)->page($page)->select();
            foreach ($data as $key => $value) $data[$key] = $this->handler($value);
            return $data;
        } catch (Exception $e) {
            return null;
        }
    }

}
